//
//  UITextField+YDYExtension.m
//  DYSisterAPP
//
//  Created by 杨德勇 on 16/7/27.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "UITextField+YDYExtension.h"

@implementation UITextField (YDYExtension)
-(void)setYdy_placeholderColor:(UIColor *)ydy_placeholderColor{
        NSString *oldPlaceholder = self.placeholder;
        //防止还没有label的时候设置颜色
        self.placeholder = @"  ";
        self.placeholder = oldPlaceholder;
    
    
    
        //防止传空值过来恢复默认
        if (ydy_placeholderColor == nil) {
            ydy_placeholderColor = [UIColor colorWithRed:0 green:0 blue:0.0980392 alpha:0.22];
        }
    
        [self setValue:ydy_placeholderColor forKeyPath:@"placeholderLabel.textColor"];
}
-(UIColor *)ydy_placeholderColor{
    return [self valueForKeyPath:@"placeholderLabel.textColor"];
}

//-(void)setPlaceholderColor:(UIColor *)placeholderColor{
//    NSString *oldPlaceholder = self.placeholder;
//    //防止还没有label的时候设置颜色
//    self.placeholder = @"  ";
//    self.placeholder = oldPlaceholder;
//    
//    
//    
//    //防止传空值过来恢复默认
//    if (placeholderColor == nil) {
//        placeholderColor = [UIColor colorWithRed:0 green:0 blue:0.0980392 alpha:0.22];
//    }
//    
//    [self setValue:placeholderColor forKeyPath:@"placeholderLabel.textColor"];
//}
//- (UIColor *)placeholderColor
//{
//    return [self valueForKeyPath:@"placeholderLabel.textColor"];
//}
@end
